package com.sxz.sbs.module.message.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sxz.sbs.R;
import com.sxz.sbs.module.message.mode.MyMessageBean;
import com.sxz.sbs.constant.TypeConstant;
import com.sxz.sbs.util.TimeUtils;

import java.util.List;

/**
 * 消息类型适配器
 */

public class MyMessageAdapter extends BaseQuickAdapter<MyMessageBean, BaseViewHolder> {
    public MyMessageAdapter(@Nullable List<MyMessageBean> data) {
        super(R.layout.item_message_type_layout, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, MyMessageBean item) {
        helper.setText(R.id.tv_message_type_name, item.getTitle());
        helper.setText(R.id.tv_message_type_first, item.getDiscription());
        if (!item.getTime().equals("")) {
            helper.setText(R.id.tv_message_type_date, TimeUtils.timeGap(item.getTime()));
        } else {
            helper.setText(R.id.tv_message_type_date, "00:00");
        }

        if (item.getIsRed() == 1) {
            helper.setVisible(R.id.iv_red_dot, true);
        } else {
            helper.setVisible(R.id.iv_red_dot, false);
        }
        if (item.getValue() == TypeConstant.NOTICE_MESSAGE_TYPE) {
            helper.setImageResource(R.id.iv_message_type, R.drawable.ic_notice);
        } else if (item.getValue() == TypeConstant.APPROVE_MESSAGE_TYPE) {
            helper.setImageResource(R.id.iv_message_type, R.drawable.ic_approval);
        } else if (item.getValue() == TypeConstant.WARM_MESSAGE_TYPE) {
            helper.setImageResource(R.id.iv_message_type, R.drawable.ic_remind);
        }
    }
}
